/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rdb.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Bich Tran Van
 */
@Entity
@Table(name = "Students")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Students.findAll", query = "SELECT s FROM Students s"),
    @NamedQuery(name = "Students.findById", query = "SELECT s FROM Students s WHERE s.id = :id"),
    @NamedQuery(name = "Students.findByEnRoll", query = "SELECT s FROM Students s WHERE s.enRoll = :enRoll"),
    @NamedQuery(name = "Students.findByStuName", query = "SELECT s FROM Students s WHERE s.stuName = :stuName"),
    @NamedQuery(name = "Students.findByStuPhone", query = "SELECT s FROM Students s WHERE s.stuPhone = :stuPhone"),
    @NamedQuery(name = "Students.findByStuAddress", query = "SELECT s FROM Students s WHERE s.stuAddress = :stuAddress"),
    @NamedQuery(name = "Students.findByStuEmail", query = "SELECT s FROM Students s WHERE s.stuEmail = :stuEmail"),
    @NamedQuery(name = "Students.findByStatus", query = "SELECT s FROM Students s WHERE s.status = :status")})
public class Students implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Size(max = 10)
    @Column(name = "enRoll")
    private String enRoll;
    @Size(max = 255)
    @Column(name = "stuName")
    private String stuName;
    @Size(max = 255)
    @Column(name = "stuPhone")
    private String stuPhone;
    @Size(max = 255)
    @Column(name = "stuAddress")
    private String stuAddress;
    @Size(max = 255)
    @Column(name = "stuEmail")
    private String stuEmail;
    @Size(max = 255)
    @Column(name = "status")
    private String status;
    @OneToMany(mappedBy = "studentId")
    private List<StudentExams> studentExamsList;
    @JoinColumn(name = "CourseId", referencedColumnName = "Id")
    @ManyToOne
    private Courses courseId;

    public Students() {
    }

    public Students(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getEnRoll() {
        return enRoll;
    }

    public void setEnRoll(String enRoll) {
        this.enRoll = enRoll;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public String getStuPhone() {
        return stuPhone;
    }

    public void setStuPhone(String stuPhone) {
        this.stuPhone = stuPhone;
    }

    public String getStuAddress() {
        return stuAddress;
    }

    public void setStuAddress(String stuAddress) {
        this.stuAddress = stuAddress;
    }

    public String getStuEmail() {
        return stuEmail;
    }

    public void setStuEmail(String stuEmail) {
        this.stuEmail = stuEmail;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @XmlTransient
    public List<StudentExams> getStudentExamsList() {
        return studentExamsList;
    }

    public void setStudentExamsList(List<StudentExams> studentExamsList) {
        this.studentExamsList = studentExamsList;
    }

    public Courses getCourseId() {
        return courseId;
    }

    public void setCourseId(Courses courseId) {
        this.courseId = courseId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Students)) {
            return false;
        }
        Students other = (Students) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rdb.entities.Students[ id=" + id + " ]";
    }
    
}
